package hiring.tong.com.talent.Listener;

import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.http.HttpServletRequest;

/**
 * Application Lifecycle Listener implementation class TalentLoginListener
 *
 */
public class TalentLoginListener implements ServletRequestAttributeListener {

   //失败登录次数
  public static int failcount; 

	/**
     * @see ServletRequestAttributeListener#attributeRemoved(ServletRequestAttributeEvent)
     */
    public void attributeRemoved(ServletRequestAttributeEvent arg0)  { 
         // TODO Auto-generated method stub
    }

	/**
     * @see ServletRequestAttributeListener#attributeAdded(ServletRequestAttributeEvent)
     */
    public void attributeAdded(ServletRequestAttributeEvent requestAttributeEvent)  { 
         // TODO Auto-generated method stub
    	String requestName=requestAttributeEvent.getName();
    	HttpServletRequest request=(HttpServletRequest)requestAttributeEvent.getServletRequest();
    	if("loginfail".equals(requestName)){
    		failcount++;
    		request.getSession().setAttribute("failcount", failcount);
    	}
    }

	/**
     * @see ServletRequestAttributeListener#attributeReplaced(ServletRequestAttributeEvent)
     */
    public void attributeReplaced(ServletRequestAttributeEvent arg0)  { 
         // TODO Auto-generated method stub
    }

	}

